package com.aaa.entity;

import com.sun.xml.internal.ws.api.pipe.ServerTubeAssemblerContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/8/22 8:51
 * @description：
 * @modified By：
 * @version:
 */
@Component
public class Student {
    @Value("1000")
    private int id;
    @Value("尚腾飞")
    private String name;
    //以类型自动注入，如果类型不匹配，按照名字
    @Autowired
    private  Teacher teacher2;
    @Autowired
    /**
     * 如果同类型的bean有多个，必须使用注解Qualifier限定符特殊指定需要注入的bean
     * 如若不然，产生bean迷失现象
     */
    @Qualifier(value = "androidPhone")
    private Phone phone;


    public Phone getPhone() {
        return phone;
    }

    public void setPhone(Phone phone) {
        this.phone = phone;
    }

    public Student() {
        System.out.println("student实例化无参构造器");
    }

    public Student(int id, String name, Teacher teacher) {
        this.id = id;
        this.name = name;
        this.teacher2 = teacher;
    }

    public void introduce(){
        System.out.println("我是"+name+"id："+id+"老师是："+teacher2.getName());
    }
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Teacher getTeacher2() {
        return teacher2;
    }

    public void setTeacher2(Teacher teacher) {
        this.teacher2 = teacher;
    }

    public static void main(String[] args) {
     /*   //控制正转的时候
        Teacher teacher = new Teacher();
        teacher.setName("陈建");
        teacher.setId(10000);
        Student student = new Student();
        student.setId(2000);
        student.setName("尚腾飞");
        student.setTeacher(teacher);
        student.introduce();*/
    }
}
